package com.tom.architect02.mnbase.annotation;

import androidx.annotation.IntDef;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

import com.tom.architect02.R;
import com.tom.architect02.mnbase.annotation.apt.BindView;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class AnnotationActivity extends AppCompatActivity {

    @BindView(value = "tom", id = 1)
    TextView mTextView;

    enum WeekDay {SUNDAY, MONDAY}

    // 枚举是非常占用内存的: 占据12字节对象头+对象属性内容+8字节的对齐。
    private static WeekDay mCurrentDay;

    // 如何优化？@IntDef 标识其他注解
    public static final int SUNDAY = 0;
    public static final int MONDAY = 1;

    @IntDef({SUNDAY, MONDAY})
    @Target({ElementType.PARAMETER, ElementType.FIELD})
    @Retention(RetentionPolicy.SOURCE)
    @interface WekDay {
    }
    @WekDay
    private static int mCurrentIntDay;
    public static void setCurrentDay(@WekDay int cDay) {
        mCurrentIntDay = cDay;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_annotation);

        setCurrentDay(SUNDAY);
    }
}